package com.sj.leetcode.editor.cn;

import java.util.*;
public class Main {
    private static class Node{
        int data;
        Node leftchild;
        Node rightchild;
        Node(int data){
            this.data = data;
        }
    }


    public static void main(String[] args) {
        Node node1 = new Node(1);
        Node node2 = new Node(3);
        Node node3 = new Node(2);
        node1.leftchild = node2;
        node1.rightchild = node3;

        m(node1);

    }

    public static void m(Node node){
        if(node == null){
            return;
        }
        Node tmp = node;
        Stack<Node> stack = new Stack<Node>();
        while(tmp == null || !stack.isEmpty()){
            while(tmp !=null){
                stack.push(tmp);
                tmp = tmp.leftchild;
            }
            tmp = stack.pop();
            System.out.print("tmp.data："+tmp.data);
            if(tmp.rightchild!=null){
                tmp = tmp.rightchild;
            } else{
                tmp =null;
            }
        }
    }

}
